package by.msokoloff.javaweb2015.dataaccess.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import by.msokoloff.javaweb2015.dataaccess.AdmUserDao;
import by.msokoloff.javaweb2015.datamodel.AdmUser;
import by.msokoloff.javaweb2015.datamodel.AdmUser_;
import by.msokoloff.javaweb2015.datamodel.enums.AdmUserRole;
import by.msokoloff.javaweb2015.datamodel.enums.AdmUserStatus;

@Repository
public class AdmUserDaoImpl extends AbstractDaoImpl<AdmUser> implements	AdmUserDao {

	protected AdmUserDaoImpl() {
		super(AdmUser.class);
	}

	@Override
	public AdmUser create(AdmUser entity) {
		entity.setCreationDate(new Date());
		return super.create(entity);
	}
	
	@Override
	public List<AdmUser> getByStatus(AdmUserStatus status) {
		return super.getByField(AdmUser_.status, status);
	}

	@Override
	public List<AdmUser> getByRole(AdmUserRole role) {
		return super.getByField(AdmUser_.role, role);
	}
}
